#!/usr/bin/perl
#
#

$topOf = $ARGV[0];

while($line=<STDIN>) {
	chomp($line);
	if($line=~/^$topOf:\s+(.+)/) {
		@words = split(/\s+/,$1);
		foreach $word (@words) {
			$count{$word}++;
			$totalCount++;
		}
	}
}

$p=0;
foreach $word (sort {$count{$b}<=>$count{$a}} keys %count) {
	my($c);
	$c = $count{$word};
	$p = $p + $c*100/$totalCount;
	print $word."\t".$c."\t".$p."\n";
}
